package com.gpy.hospital.cms.service.impl;

import com.gpy.hospital.cms.dao.HuiFuMapper;
import com.gpy.hospital.cms.dao.HuiFuVoMapper;
import com.gpy.hospital.cms.dao.LiuYanMapper;
import com.gpy.hospital.cms.pojo.HuiFu;
import com.gpy.hospital.cms.service.IHuiFuService;
import com.gpy.hospital.cms.vo.HuiFuVo;
import com.gpy.hospital.common.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author
 * @Date 2020/3/1 21:46
 * @Desc
 **/
@Service
public class HuiFuServiceImpl implements IHuiFuService {
    @Autowired
    private HuiFuVoMapper huiFuVoMapper;
    @Autowired
    private HuiFuMapper huiFuMapper;
    @Autowired
    private LiuYanMapper liuYanMapper;

    @Override
    public List<HuiFuVo> getAll() {
        List<HuiFuVo> huiFuVoList = huiFuVoMapper.getAll();
        return huiFuVoList;
    }

    @Override
    public ServerResponse add(HuiFu huiFu) {
        huiFu.setStatus("1");
        int result = huiFuMapper.insert(huiFu);
        int a = liuYanMapper.setStatus(huiFu.getLiuyanId());
        if (result > 0) {
            return ServerResponse.createBySuccessMessage("成功！");
        }
        return ServerResponse.createByErrorMessage("失败！");
    }

    @Override
    public ServerResponse delete(Integer liuYanId) {
        int result = huiFuMapper.deleteByPrimaryKey(liuYanId);
        if (result > 0) {
            return ServerResponse.createBySuccessMessage("成功！");
        }
        return ServerResponse.createByErrorMessage("失败！");
    }
}
